GROOVY-11968: SC: trait static field access generates invalid bytecod…#2495
Merged
paulk-asert merged 1 commit intoapache:masterfrom May 1, 2026
Merged
GROOVY-11968: SC: trait static field access generates invalid bytecod…#2495paulk-asert merged 1 commit intoapache:masterfrom
paulk-asert merged 1 commit intoapache:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes GROOVY-11968 (follow-up to GROOVY-11907) where statically compiled trait static-field access could route sub-expressions through the regular (non-static) call-site writer, producing invalid bytecode under indy=false.
Changes:
- Track whether the current statically compiled method contains any
DYNAMIC_RESOLUTIONsub-expressions (via an AST scan). - Ensure the regular
CallSiteWriterper-method prologue is emitted at method entry when such dynamic-resolution sub-expressions exist. - Add a regression test that compiles and runs the reproducer script with
indy=trueandindy=false.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy11968.groovy | New regression test covering helper verification under both indy modes |
| src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesWriterController.java | Detects presence of DYNAMIC_RESOLUTION within statically compiled methods/ctors |
| src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java | Emits regular call-site writer method prologue when needed to avoid invalid locals |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2495 +/- ##
==================================================
+ Coverage 67.0917% 67.1794% +0.0878%
- Complexity 31765 31852 +87
==================================================
Files 1465 1465
Lines 123373 123511 +138
Branches 22107 22138 +31
==================================================
+ Hits 82773 82974 +201
+ Misses 33493 33400 -93
- Partials 7107 7137 +30
🚀 New features to boost your workflow:
|
blackdrag
reviewed
Apr 29, 2026
…e under indy=false (GROOVY-11907 follow-up)
jamesfredley
pushed a commit
to apache/grails-core
that referenced
this pull request
May 2, 2026
Re-audited every Groovy 6 workaround in this canary against the latest Apache Groovy master. Three fixes have merged and are present in the 6.0.0-SNAPSHOT artifact (latest publication: 2026-05-02 11:47:43 UTC, build #546), so the corresponding workarounds can be removed. GROOVY-11968 (apache/groovy#2495), merged 2026-05-01 03:40 UTC, SHA 84f2f37c4f93d6ea44ad8bc76570704c84499c6b - grails-geb/.../ContainerSupport.groovy: revert @CompileDynamic to @CompileStatic now that the trait-static-field VerifyError under indy=false no longer triggers. GROOVY-11967 (apache/groovy#2493), merged 2026-05-01 09:37 UTC, SHA 406feaf5082f1741c318f924b520c4c27bfa0754 - DefaultConstraintFactory.groovy: collapse the two explicit constructors back to a single constructor with a default-valued List parameter; the @CompileStatic VerifyError on the synthesised bridge constructor no longer reproduces. - MappingContextAwareConstraintFactory.groovy: same collapse. GROOVY-11966 (apache/groovy#2492), merged 2026-05-01 18:58 UTC, SHA 8dde1c84134ef6fdeecf26b5cbb5183d5aab4dac - GroovyPageCompiler.groovy: drop the parallelism guard and the grails.gsp.compiler.parallelism system property; restore the original Executors.newFixedThreadPool(availableProcessors() * 2) sizing now that AnnotationNode.isTargetAllowed -> ListHashMap is thread-safe again. - AbstractGroovyTemplateCompiler.groovy: same restoration; drop the grails.views.compiler.parallelism system property. Verified locally on Java 21 / Groovy 6.0.0-SNAPSHOT build #546: ./gradlew :grails-datamapping-validation:compileGroovy ./gradlew :grails-datamapping-core:compileGroovy ./gradlew :grails-gsp-core:compileGroovy ./gradlew :grails-views-core:compileGroovy ./gradlew :grails-geb:compileTestFixturesGroovy -> all BUILD SUCCESSFUL The remaining workarounds (TraitReceiverTransformer static-method override loss, MetaClassImpl genericGetMethod hijack on GORM entities, @CompileStatic named-argument render(Map) silent no-op, smart-cast in 'if (cond && !(x instanceof Y))', VariableScopeVisitor NPE, and ConfigObject [] mutation) have no upstream fix yet and stay in place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…e under indy=false (GROOVY-11907 follow-up)
https://issues.apache.org/jira/browse/GROOVY-11968